<%--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">--%>
<%@ page contentType="text/html;charset=UTF-8" language="java"  pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="spring" uri="/WEB-INF/lib/spring.tld"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f" %>
<%@ taglib prefix="z" uri="/WEB-INF/lib/zerdoor.tld"%>
<c:set value="${pageContext.request.contextPath}" var="path" scope="page"/>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title><spring:message code="chatMain.message.msg11" /></title>


    <script type="text/javascript">
        //Ajax文件上传
        function f_file_upload_deliverable(stageId){

            if($("#deliverable").html().trim() != ""){
                if(!confirm("<spring:message code='chatMain.message.msg12' />")){
                    return;
                }
            }


            //var result =/\.[^\.]+/.exec($("#fulAchievements").val());

            var path = $("#fulAchievements_deliverable").val();

            var pos1 = path.lastIndexOf("\\");
            var pos2 = path.lastIndexOf(".");
            var pos = path.substring(pos1 + 1, pos2);

            var fileName = path.substring(pos1+1,pos2);

            var str = $("#fulAchievements_deliverable").val().split(".");
            var result = path.substring(pos2 + 1,path.length );

            var rars = ".rar.zip.7z.cab.txt.doc.docx.xls.xlsx.RAR.ZIP.7Z.CAB.TXT.DOC.DOCX.XLS.XLSX.bmp.jpg.dib.jpeg.png.jfif.jpe.tif.tiff.gif.psd.3ds.BMP.JPG.DIB.JPEG.PNG.JFIF.JPE.TIF.TIFF.GIF.PSD.3DS";


            //文件类型 false为压缩包
            var boo = false;

            if(rars.indexOf(result) > -1){
//                console.log("压缩包");
            }else{

                alert("<spring:message code='chatMain.message.msg13' />")
                $("#fulAchievements_deliverable").val("");
                return;
            }

            $.ajaxFileUpload({
                url: '${path}/fileUpload/upload_resource_file.html',
                secureuri: false,
                fileElementId: 'fulAchievements_deliverable',
                //dataType: 'json',
                success: function (data) {
                    //data = $.parseJSON(data);

                    var data2 = data.split(",");

                    var url = data2[0].replace(" ","");
                    fileName = data2[1].replace(" ","");
                    try{
                        //保存
                        f_saveStageDeliverable(url,stageId);
                    }catch(e) {

                        console.log(e)
                    }

                },
                error:function(data){

                    console.log("error");
                    console.log(data);
                }
            });
        }

        function f_saveStageDeliverable(url,id){
            $.post("${path}/itemStage/saveStageDeliverable.html",{deliverable:url,stageId:id},
                    function(data, textStatus, jqXHR){
                        if("success" == data){

                        <%--<a class='downloadSpan' href='${path}/fileDownload/download_file.html?res_url="+url+"'>下载</a>--%>
                            var html = "<span><spring:message code='chatMain.message.msg14' /><a href=\"javascript:f_download('"+url+"')\"><spring:message code='chatMain.message.msg5' /></a></span><br/>";

                            $("#deliverable").html( html);
                        }

                    });
        }
    </script>
</head>
<body>

<div class="member_room_step">
    <c:forEach var="stageInfo" items="${stageList}" varStatus="k">
        <div class="room_step_list">
            <h3>${stageInfo.stage}
                <c:if test="${stageInfo.stage_status == 134001}">
                    <span ><spring:message code='chatMain.message.msg15' /></span>
                </c:if>
                <c:if test="${stageInfo.stage_status == 134002 || stageInfo.stage_status == 134003}">
                    <span class="on"><spring:message code='chatMain.message.msg16' /></span>
                </c:if>
                <c:if test="${ stageInfo.stage_status == 134004}">
                    <span ><spring:message code='chatMain.message.msg17' /></span>
                </c:if>

            </h3>
            <div class="room_step_now" style="text-align:left; padding:0px;" >
                <span><spring:message code='chatMain.message.msg18' />${stageInfo.stage_status_name}</span><br/>
                <span><spring:message code='chatMain.message.msg19' />${stageInfo.scale} %</span><br/>
                <span><spring:message code='chatMain.message.msg20' />${stageInfo.result_claim}</span><br/>
                <span><spring:message code='chatMain.message.msg21' />${stageInfo.start_time}</span><br/>
                <span><spring:message code='chatMain.message.msg22' />${stageInfo.pay_date}</span><br/>
                <span id="deliverable">
                    <c:if test="${stageInfo.deliverable != null && stageInfo.deliverable != ''}">

                        <span><spring:message code='chatMain.message.msg14' /><a style="color: #0000ff;" href="javascript:f_download('${stageInfo.deliverable}')"><spring:message code='chatMain.message.msg5' /></a></span><br/>
                    </c:if>
                </span>
            </div>
            <p>
                <c:if test="${stageInfo.stage_status == 134001}">
                    <a href="" class="btn_step"><spring:message code='chatMain.message.msg23' /></a>
                </c:if>
                <c:if test="${stageInfo.stage_status == 134002}">
                    <a href="" class="btn_step"><spring:message code='chatMain.message.msg23' /></a>
                </c:if>
                <c:if test="${stageInfo.stage_status == 134003}">
                    <a onclick="javascript:$(this).next().trigger('click')" class="btn_step"><spring:message code='chatMain.message.msg24' /></a>
                    <input style="display: none" type="file" name="file" id="fulAchievements_deliverable" onchange="f_file_upload_deliverable(${stageInfo.stage_id})">
                </c:if>
                <c:if test="${stageInfo.stage_status == 134004}">
                    <c:if test="${!k.last}"><a  class="btn_step"><spring:message code='chatMain.message.msg17' /></a></c:if>
                    <c:if test="${k.last}"><a href="javascript:void(0)" class="btn_step" onclick="openWin()"><spring:message code='chatMain.message.msg25' /></a></c:if>

                </c:if>
            </p>
        </div>
    </c:forEach>
    <%--<div class="room_step_list">--%>
    <%--<h3>第二阶段<span class="on">当前阶段</span></h3>--%>
    <%--<div class="room_step_now">--%>
    <%--<p>尚未提交稿件</p>--%>
    <%--<p>已历时：3天7小时</p>--%>
    <%--</div>--%>
    <%--<p><a href="" class="btn_step">通过本阶段</a></p>--%>
    <%--</div>--%>
    <%--<div class="room_step_list">--%>
    <%--<h3>第一阶段<span>已完成</span></h3>--%>
    <%--<p><img src="upload/1.jpg" width="292" height="180" /></p>--%>
    <%--<p><a href="" class="btn_step">下载阶段附件</a></p>--%>
    <%--</div>--%>
</div>
<div class="member_mroom_contact">
    <ul>
        <li class="clearfix"><a href="http://wpa.qq.com/msgrd?v=3&uin=2217239218&site=qq&menu=yes"><spring:message code='chatMain.message.msg26' /></a><a href="${path}/arbitration/arbitrationDetail.html?contractId=${contractId}" class="nomr"><spring:message code='chatMain.message.msg27' /></a></li>
        <%--<li class="btncancel"><a href="">申请取消项目</a></li>--%>
        <%--<li>若取消，项目将就此终止，需征得参与各方的一致同意</li>--%>
    </ul>
</div>

</body>
</html>
